﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace GH.Web.Welfare
{
    public partial class RecuperatePlanSumirisePrint : BasePage.PageBase
    {
        #region 画面初始化

        public int beignYear = System.DateTime.Now.Year;
        public int theTotal = 0;
        public int jh1Total = 0;
        public int jh2Total = 0;
        public int jh3Total = 0;
        public int jh4Total = 0;
        public int jh5Total = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BLL.RecuperatePlan bllRecuperateCondation = new GH.BLL.RecuperatePlan();
                string theDate = Session["SelectCurrentYear"].ToString();
                string strWhere = " 1=1";
                if (Request.QueryString["RightsFlg"].ToString() == "Summary")
                {
                    //strWhere += " AND  会员基本信息.单位=" + this.Session["UnionSelect"].ToString();
                }
                else if (Request.QueryString["RightsFlg"].ToString() == "SELECT")
                {
                    strWhere += " AND  员工疗养计划.单位=" + this.Session["UnionSelect"].ToString();                    
                }
                DataSet dsRecord = bllRecuperateCondation.GetList(strWhere, theDate);
                rptList.DataSource = dsRecord;
                rptList.DataBind();
                

                foreach (DataRow item in dsRecord.Tables[0].Rows)
                {
                    if (item["计划人数1"].ToString() != "")
                    {
                        jh1Total += Convert.ToInt32(item["计划人数1"]);
                    }
                    if (item["计划人数2"].ToString() != "")
                    {
                        jh2Total += Convert.ToInt32(item["计划人数2"]);
                    }
                    if (item["计划人数3"].ToString() != "")
                    {
                        jh3Total += Convert.ToInt32(item["计划人数3"]);
                    }
                    if (item["计划人数4"].ToString() != "")
                    {
                        jh4Total += Convert.ToInt32(item["计划人数4"]);
                    }
                    if (item["计划人数5"].ToString() != "")
                    {
                        jh5Total += Convert.ToInt32(item["计划人数5"]);
                    }
                }
                theTotal = jh1Total + jh2Total + jh3Total + jh4Total + jh5Total;

                //SetDataInit(strWhere);
            }
            beignYear = Convert.ToInt32(Session["SelectCurrentYear"]);

        }

        public string GetTotal(object a1, object a2, object a3, object a4, object a5)
        {
            int total = 0;
            if (a1.ToString() != "")
            {
                total += Convert.ToInt32(a1);
            }
            if (a2.ToString() != "")
            {
                total += Convert.ToInt32(a2);
            }
            if (a3.ToString() != "")
            {
                total += Convert.ToInt32(a3);
            }
            if (a4.ToString() != "")
            {
                total += Convert.ToInt32(a4);
            }
            if (a5.ToString() != "")
            {
                total += Convert.ToInt32(a5);
            }

            if (total == 0)
            {
                return "";
            }
            else
            {
                return total.ToString();
            }
        }

        #endregion 画面初始化
    }
}
